import { Module } from '@nestjs/common';
import { RedisModule } from '@nestjs-modules/ioredis';
import {
  getDataBase
} from './config/database.config';
import { TypeOrmModule  } from '@nestjs/typeorm';
import { ScheduleModule } from '@nestjs/schedule';
import { VideoModule } from './entity/video/video.module';
import { redisConfig } from './config/redis.config';
import { AppController } from './app.controller';

@Module({
  imports: [
    ScheduleModule.forRoot(),
    TypeOrmModule.forRootAsync({
      useFactory:async () => {
        return await getDataBase()
      }
    }),
    RedisModule.forRoot({
      type: "single",
      url: `redis://${redisConfig.host}:${redisConfig.port}`,
      options:{
        db: Number(!process.env.ServerApp ? 2 : process.env.redisdb),
        password: redisConfig.password
      }
    }),
    VideoModule
  ],
  controllers: [AppController],
  providers: [],
})
export class AppModule {}
